﻿<?xml version="1.0" encoding="utf-8"?><Articles><Article><ArticlesID>880</ArticlesID><Title>H&amp;#224;m chuyển đổi kiểu số sang thứ tự</Title><Body>&amp;lt;p&amp;gt;H&amp;amp;agrave;m sau đ&amp;amp;acirc;y sẽ chuyển đổi kiểu số sang thứ tự trong tiếng anh:&amp;lt;/p&amp;gt;
&amp;lt;blockquote&amp;gt;
&amp;lt;p&amp;gt;1 --&amp;amp;gt; 1st&amp;lt;br /&amp;gt;
2 --&amp;amp;gt; 2nd&amp;lt;br /&amp;gt;
3 --&amp;amp;gt; 3rd&amp;lt;br /&amp;gt;
...&amp;lt;br /&amp;gt;
&amp;amp;nbsp;&amp;lt;/p&amp;gt;
&amp;lt;/blockquote&amp;gt;
&amp;lt;p&amp;gt;Code C#&amp;lt;/p&amp;gt;
&amp;lt;pre class=&amp;quot;brush: csharp;&amp;quot; title=&amp;quot;code&amp;quot;&amp;gt;
public string AddOrdinal(int num)
{
        switch(num % 100)
        {
                case 11:
                case 12:
                case 13:
                        return num.ToString() + &amp;amp;quot;th&amp;amp;quot;;
        }

        switch(num % 10)
        {
                case 1:
                        return num.ToString() + &amp;amp;quot;st&amp;amp;quot;;
                case 2:
                        return num.ToString() + &amp;amp;quot;nd&amp;amp;quot;;
                case 3:
                        return num.ToString() + &amp;amp;quot;rd&amp;amp;quot;;
                default:
                        return num.ToString() + &amp;amp;quot;th&amp;amp;quot;;
        }

}
&amp;lt;/pre&amp;gt;
&amp;lt;p&amp;gt;Code VB.NET&amp;lt;/p&amp;gt;
&amp;lt;pre class=&amp;quot;brush: vb;&amp;quot; title=&amp;quot;code&amp;quot;&amp;gt;
    Public Function AddOrdinal(ByVal num As Integer) As String
        Select Case num Mod 100
            Case 11, 12, 13
                Return num.ToString() &amp;amp;amp; &amp;amp;quot;th&amp;amp;quot;
        End Select

        Select Case num Mod 10
            Case 1
                Return num.ToString() &amp;amp;amp; &amp;amp;quot;st&amp;amp;quot;
            Case 2
                Return num.ToString() &amp;amp;amp; &amp;amp;quot;nd&amp;amp;quot;
            Case 3
                Return num.ToString() &amp;amp;amp; &amp;amp;quot;rd&amp;amp;quot;
            Case Else
                Return num.ToString() &amp;amp;amp; &amp;amp;quot;th&amp;amp;quot;

        End Select
    End Function&amp;lt;/pre&amp;gt;
&amp;lt;p&amp;gt;&amp;amp;nbsp;&amp;lt;/p&amp;gt;</Body><CommentEnabled>True</CommentEnabled><ViewCount>0</ViewCount><ReleaseDate>4/18/2010 8:41:02 AM</ReleaseDate><TotalComment>0</TotalComment><IsMedia>False</IsMedia><IsPicture>False</IsPicture><IsVote>True</IsVote><ArticlePassword /><PostVisible>0</PostVisible><ArticlePath>/2010/4/9/Ham-chuyen-doi-kieu-so-sang-thu-tu-370</ArticlePath><Approved>True</Approved><ImagePath /><CategoryId>27</CategoryId><ArrayCatID>27|25</ArrayCatID></Article></Articles>